package com.csd.action.teacher;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.csd.helper.ActionResult;
import com.csd.helper.IConstant;
import com.csd.helper.SessionManager;
import com.csd.pojo.Project;
import com.csd.serviceImpl.ProjectService;
import com.csd.vo.UserVO;
/**
 * 
 * 查询教师指导项目的Action类
 * @author 尹华彬
 * @version 1.0
 * 
 * <br> 修订时间：2009-12-17
 * <br> 修改原因：创建文件
 * <br> 修改人：尹华彬
 * 
 * <br> 
 * 
 */

public class TeacherGuideAction {
   
	//老师指导的项目
    private List<Project>  project;
	  
    private ProjectService projectService;
    
	public ProjectService getProjectService() {
		return projectService;
	}


	public void setProjectService(ProjectService projectService) {
		this.projectService = projectService;
	}


	public List<Project> getProject() {
		return project;
	}


	public void setProject(List<Project> project) {
		this.project = project;
	}




	public String execute() {
		/** 通过老师ID查出老师指导的项目 */
		String result = ActionResult.fail;
		Integer teacherID = null;
		//通过session获得teacherID
		try {
			HttpSession httpSession = ServletActionContext.getRequest().getSession();
			UserVO value = (UserVO)httpSession.getAttribute(IConstant.userVO);
			if(value == null){
				throw  new Exception("用户未登录异常");
			}
			teacherID = value.getUserID();
		} catch (Exception e) {
			e.printStackTrace();
			return result;
		}
		if(teacherID == null)
			return result;
		//查询老师的指导项目
        project = projectService.listProjectByTeacherID(teacherID);
        result = ActionResult.success;
        
		return result;
	}
}
